<?php
#####################################
# * @Author: lehieu008              #
# * @Email: lehieu008@gmail.com     #
# * @Copyright: 2008 - 2010         #
#####################################
if(!defined('BASEPATH'))exit('No direct script access allowed');
class Employ_module extends Controller
{
    function __construct()
    {
        parent::Controller();
    }
    
    function reliable($module = true)
    {
        if($module == true)
        {
            $limit = JOB_MODULE_ROWS;
            $sql = "SELECT jobID, jobSection, jobCategory, jobTitle, jobView FROM {PRE}job ";
        }
        else
        {
            $limit = RELIABLE_JOB_ROWS;
            $sql = "SELECT jobID, jobSection, jobCategory, jobTitle, jobView, jobPostDate, preName FROM {PRE}job ";
            $sql .= "INNER JOIN {PRE}province ON {PRE}job.jobProvince = {PRE}province.preID ";
        }
        $sql .= "WHERE jobReliable = 1 AND jobStatus = 1 AND jobExpireDate >= ".time()." ";
        $sql .= "ORDER BY RAND() LIMIT 0,$limit";
        $data['rows'] = $this->global_model->fetch($sql);
        $data['module'] = $module;
        #Load View
        $this->load->view('job/reliable', $data);
    }
    
    function popular()
    {
        $sql = "SELECT jobID, jobSection, jobCategory, jobTitle, jobView, jobPostDate FROM {PRE}job ";
        $sql .= "WHERE jobStatus = 1 AND jobExpireDate >= ".time()." ";
        $sql .= "ORDER BY jobView DESC LIMIT 0,".JOB_MODULE_ROWS;
        $data['rows'] = $this->global_model->fetch($sql);
        #Load View
        $this->load->view('job/popular', $data);
    }
    
    function category($category = 0, $current = 0)
    {
        $sql = "SELECT jobID, jobSection, jobCategory, jobTitle, jobView, jobPostDate FROM {PRE}job ";
        $sql .= "WHERE jobCategory = $category AND jobID != $current AND jobStatus = 1 AND jobExpireDate >= ".time()." ";
        $sql .= "ORDER BY RAND() LIMIT 0,".JOB_MODULE_ROWS;
        $data['rows'] = $this->global_model->fetch($sql);
        #Load View
        $this->load->view('job/category', $data);
    }
}